<template>
  <div class="app-container">
    <el-form ref="form"
             :model="form"
             :label-position="labelPosition"
             class="register-form">
      <el-row :gutter="40">
        <el-col :span="8">
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="报告文号">
                <el-input v-model="form.reportNo" type="text" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="防伪编码">
                <el-input v-model="form.antiCounterfeitingCoding" type="text" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="客户名称（被审验单位名称）">
                <el-input v-model="form.customerName" type="text" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="客户营业执照号">
                <el-input v-model="form.customerBusinessLicense" type="text" readonly />
              </el-form-item>
            </el-col>
            <el-col :span="24" v-judgeAccount="0">
              <el-form-item label="事务所名称">
                <el-input v-model="form.firmName" type="text" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="12" v-judgeAccount="0">
              <el-form-item label="事务所行政区划">
                <el-input v-model="form.office.province" type="text" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="首次承接业务时间">
                <el-input v-model="form.firstBusinessTime" type="text" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="12" v-judgeAccount="0">
              <el-form-item label="是否具有证券资格">
                <el-input v-model="form.hasSecurities" type="text" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="是否属于证券业务">
                <el-input v-model="form.isSecuritiesBusiness" type="text" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="备注">
                <el-input v-model="form.officeRemarks" type="text" readonly/>
              </el-form-item>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="16">
          <el-row :gutter="20">
            <el-col :span="6">
              <el-form-item label="意见类型">
                <el-input v-model="form.opinionType" type="text" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="报备类型">
                <el-input v-model="form.reportType" type="text" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="审计年度">
                <el-input v-model="form.auditYear" type="text" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="报告日期">
                <el-input v-model="form.reportTime" type="text" readonly/>
              </el-form-item>
            </el-col>
           <!-- <el-col :span="6">
              <el-form-item label="基础数据状态">
                <el-input v-model="form.basicDataStatus" type="text" readonly/>
              </el-form-item>
            </el-col>-->
          <!--  <el-col :span="6">
              <el-form-item label="数据匹配结果">
                <el-input v-model="form.dataMatchingResults" type="text" readonly/>
              </el-form-item>
            </el-col>-->
           <!-- <el-col :span="6">
              <el-form-item label="数据上传路径">
                <el-input v-model="form.dataUploadPath" type="text" readonly/>
              </el-form-item>
            </el-col>-->
          </el-row>
          <el-row :gutter="20" v-judgeAccount="0">
            <el-col :span="6">
              <el-form-item label="财政系统报备编码">
                <el-input v-model="form.reportCode" type="text" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="6" v-judgeAccount="0">
              <el-form-item label="财政系统报备年度">
                <el-input v-model="form.filingYear" type="text" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="6" v-judgeAccount="0">
              <el-form-item label="财政系统报备日期">
                <el-input v-model="form.filingTime" type="text" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="6" v-judgeAccount="0">
              <el-form-item label="财政系统报备状态">
                <el-input v-model="form.reportStatus" type="text" readonly/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="6">
              <el-form-item label="上传时间">
                <el-input v-model="form.uploadTime" type="text" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="收费金额（元）">
                <el-input v-model="form.chargeAmount" type="text" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="验资金额（元）">
                <el-input v-model="form.capitalVerificationAmount" type="text" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="验资币种">
                <el-input v-model="form.capitalVerificationCurrency" type="text" readonly/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="6">
              <el-form-item prop="placeOfIncorporation"
                            label="公司注册地"
              >
                <el-input v-model="form.placeOfIncorporation" type="text" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item prop="businessAddress"
                            label="业务所在地"
              >
                <el-input v-model="form.businessAddress" type="text" readonly/>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="数据修改次数">
                <el-input v-model="form.count" type="text" readonly/>
              </el-form-item>
            </el-col>
         </el-row>
          <el-row :gutter="20">
            <div v-for="(item, index) in form.assuranceBusinessDataRegisterSignatures" :key="item.registerId" style="position: relative">
              <el-col :span="6">
                <el-form-item
                  :label="`签字注会${index+1}证书号`"
                  :prop="'assuranceBusinessDataRegisterSignatures.' + index + '.registrationCertificateNo'"
                >
                  <el-input v-model="item.registrationCertificateNo" type="text" auto-complete="off" placeholder="请输入签字注师证号" readonly/>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item
                  :label="`签字注册会计师${index+1}`"
                  :prop="'assuranceBusinessDataRegisterSignatures.' + index + '.registrantName'"
                >
                  <el-input v-model="item.registrantName" type="text" auto-complete="off" placeholder="请输入签字注师姓名" readonly/>
                </el-form-item>
              </el-col>
            </div>
          </el-row>
          <el-row :gutter="20">
          <!--  <el-col :span="6">
              <el-form-item label="报告基本数据状态">
                <el-input v-model="form.reportBasicDataStatus" type="text" readonly/>
              </el-form-item>
            </el-col>-->
            <!--<el-col :span="12">
              <el-form-item label="备注（事务所导入）">
                <el-input v-model="form.officeRemarks" type="text" readonly/>
              </el-form-item>
            </el-col>-->
          </el-row>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="24">
          <el-button
            size="medium"
            type="danger"
            v-if="form.status === 0"
            @click.native.prevent="handleDelete"
          >
            删除
          </el-button>
          <el-button
            size="medium"
            type="default"
            @click.native.prevent="handleClosePage"
          >
            <span>返 回</span>
          </el-button>
          <el-button
            v-if="form.dataStatus !== '4' && form.applyForFinancialRefund === '0'"
            size="medium"
            type="warning"
            v-hasPermi="['assurance:apply:return']"
            @click.native.prevent="handleOpenReturn"
          >
            申请财政退回
          </el-button>
       <!--   <el-button
            v-if="form.dataStatus !==4"
            size="medium"
            type="danger"
            v-hasPermi="['assurance:data:void']"
            @click.native.prevent="voidData"
          >
            作废数据
          </el-button>-->
        </el-col>
      </el-row>

    </el-form>
    <!--    审批-->
    <el-dialog
      title="申请退回"
      :visible.sync="returnVisible"
      width="360px"
      :close-on-click-modal="false"
      append-to-body
      center
    >
      <el-input type="textarea" v-model="returnForm.reason" :rows="8" placeholder="请输入退回理由" />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="handleSubmitReturn">确 定</el-button>
        <el-button @click="handleCancelReturn">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 作废业务数据 -->
    <el-dialog
      title="作废业务数据原因"
      :visible.sync="voidVisible"
      width="360px"
      :close-on-click-modal="false"
      append-to-body
      center
    >
      <el-input type="textarea" v-model="commonForm.reason" :rows="8" placeholder="请输入作废原因..."></el-input>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="voidDataConfirm">确 定</el-button>
        <el-button @click="voidVisible=false;">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
  import {getAssurance, delAssurance, putReturn, voidBusinessData} from "@/api/system/assurance";
  export default {
    name: "AssuranceDetail",
    data() {
      return {
        returnVisible: false,
        voidVisible: false, // 作废业务数据弹框
        returnForm: {},
        businessId: '', // 传过来的 assuranceId
        labelPosition: "top",
        form: {
          office:{
            province:undefined
          }
        },
        commonForm: {},// 审批表单,作废业务数据
      };
    },
    created() {
      this.businessId = this.$route.query.businessId;
      this.getDetail(this.businessId);
    },
    activated() {
        this.businessId = this.$route.query.businessId;
        this.getDetail(this.businessId);
    },
    methods: {
      /**  编辑按钮操作 */
     /* handleUpdate() {
        this.$router.push({ path: '/assurance/edit', query: { businessId: this.businessId}})
      },*/
      /**  关闭按钮操作 */
      handleClosePage() {
        this.colseCurWin();
      },

      /**  删除按钮操作 */
      handleDelete() {
        var businessIdS = this.businessId;
        delAssurance(businessIdS).then(
          response => {
            this.form = response.data;
            this.$router.push({ path: '/assurance/list'});
          }
        );
      },
      handleOpenReturn() {
        this.returnVisible = true;
        this.returnForm = {
          businessId: this.businessId,
          reason: ''
        }
      },
      handleSubmitReturn() {
        this.returnVisible = false;
        putReturn(this.returnForm).then(res => {
          if(200===res.code){
            this.$message({
              type: 'success',
              message: '申请退回成功！'
            });
            this.getDetail(this.businessId);
          }else {
            this.$message({
              type: 'info',
              message: '申请退回失败！'
            });
          }
        })
        // 提交接口
      },
      handleCancelReturn() {
        this.returnVisible = false
      },
      getDetail(businessId){
        debugger
        getAssurance(businessId).then(
          response => {
            if(response.msg && response.msg == "无权限"){
              this.$message({
                message: "无权限!",
                type: 'error'
              });
              this.$router.push("/assurance/list")
            }else{
              this.form = response.data;
              // 当数据为空时，显示 -
              for(let key in this.form){
                if(this.form[key] === undefined || this.form[key] === null ){
                  this.form[key] = '-';
                }
              }
            }

          }
        );
      },
      voidData(row){
        this.voidVisible = true;
        this.commonForm = {};
        this.commonForm.businessId = this.businessId;
      },
      voidDataConfirm(){
        this.$confirm('是否确认作废该条业务数据?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          voidBusinessData(this.commonForm).then(res=>{
            this.$message({
              message: '数据作废成功!',
              type: 'success'
            });
          });
        }).then(response => {

        }).catch(function() {});
      },
    }
  };
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
  ::v-deep .el-form-item__label{
    position: relative;
    font-size: 15px;
  }
  ::v-deep .el-form-item.is-required:not(.is-no-asterisk)>.el-form-item__label:before {
    content: '';  // 去掉 * 号
  }
  ::v-deep .el-form-item.is-required:not(.is-no-asterisk)>.el-form-item__label:after {
    content: '*';  // 后置 * 号
    color: #ff4949;
    margin-right: 4px;
    right: -15px;
    top: 2px;
    position: absolute;
  }
  ::v-deep .el-input__inner{
    &::-webkit-input-placeholder {
      font-size: 13px;
    }
  }
  ::v-deep .el-date-editor.el-input, ::v-deep .el-select{
    width: 100%;
  }
  /*readonly 只读样式*/
  ::v-deep  input[readonly]{ border: 1px solid #EEF0F3;} /*input框只读样式*/
  ::v-deep  textarea[readonly]{ border: 1px solid #EEF0F3;} /*textarea框只读样式*/
  ::v-deep   .el-select{
    input[readonly]{ border: 1px solid #EEF0F3;} /*select的 input框默认就是只读的，要还原只读(带边框)样式*/
  }
  .poBtn{
    margin-top: 50px;
    display: block;
    text-align: center
  }
</style>
